﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NFine.Application.Biz;
using NFine.Code;

namespace NFine.Web.Areas.BizManage.Controllers
{
    public class WithdrawalsManageController : ControllerBase
    {

        private UserWithdrawalsApp userWithdrawalsApp = new UserWithdrawalsApp();
        private UserDetailApp userDetailApp = new UserDetailApp();

        //
        // GET: /BizManage/WithdrawalsManage/

        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="Type"></param>
        /// <param name="WithdrawalsTimeStart"></param>
        /// <param name="WithdrawalsTimeEnd"></param>
        /// <returns></returns>
        [HttpGet]
        [HandlerAjaxOnly]
        [HandlerLogin]
        public ActionResult GetListForWithdrawals(Pagination pagination, int Type, string WithdrawalsTimeStart, string WithdrawalsTimeEnd)
        {
            //userDetailApp.BalanceWithoutRecursive();
            //userDetailApp.ThreeDistributionBonus("1211", 10000, "1");
            var data = new
            {
                rows = userWithdrawalsApp.GetListForWithdrawals(pagination, Type, WithdrawalsTimeStart, WithdrawalsTimeEnd),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        [HttpPost]
        public ActionResult DoWithdrawals(string Id)
        {
            var result = userWithdrawalsApp.DoWithdrawals(Id);
            if (result > 0)
                return Success("操作成功。");
            else
                return Error("操作失败。");
        }

    }
}
